<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const handleData = (list, parentArray, type = '', allArray = []) => {
      return list.map((item) => {
        item.parentArray = parentArray;
        item.parentType = type;
        // 第一级特殊处理，父级等于本身
        item.allArray = allArray?.length ? allArray : [item.anArray];
        item.fieldRequire = item.anArray ? false : item.fieldRequire; //V8-158494
        const nextAllArray = [...item.allArray, item.anArray];
        if (item.subMetadataParams && item.subMetadataParams.length) {
          item.subMetadataParams = handleData(
            item.subMetadataParams,
            item.anArray,
            item.javaType,
            nextAllArray,
          );
        }
        if (item.subParamSettings && item.subParamSettings.length) {
          item.subParamSettings = handleData(
            item.subParamSettings,
            item.anArray,
            item.type,
            nextAllArray,
          );
        }
        return item;
      });
    };
  </script>
</body>

</html>